<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\CityLogic;
use Illuminate\Http\Request;

class CityController extends Controller
{
    //城市列表
    public function cityList(Request $request)
    {
        try {
            $rules = [
                'level' => 'sometimes|numeric',
                'created_start' => 'sometimes|date',
                'created_end' => 'sometimes|date',
                'page'=>'required|numeric|min:1',
                'page_size'=>'required|numeric|min:10',
                'money_min'=>'sometimes|numeric',
                'money_max'=>'sometimes|numeric',
            ];

            $this->verify($request->all(), $rules);
            $list = (new CityLogic())->getCityList($request->all());
            ret_json('ok','ok',$list);
        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }

    //编辑城市
    public function editCity(Request $request)
    {
        try {
            $rules = [
                'id' => 'required|numeric',
                'level'=>'required|numeric',
                'money'=>'required|numeric',
            ];

            $this->verify($request->all(), $rules);
            $list = (new CityLogic())->editCity($request->all());
            ret_json('ok','ok',$list);
        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }
}
